package me.raih.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author Raih
 * @version 1.8
 * @Time 2020/9/10  12:29
 */
public class DBUtil {

    private static DataSource dataSource;

    static {

        Properties properties = new Properties();
        InputStream resourceAsStream = DBUtil.class.getClassLoader().getResourceAsStream("druid.properties");
        try {
            properties.load(resourceAsStream);

            dataSource = DruidDataSourceFactory.createDataSource(properties);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static DataSource getDataSource(){

        return dataSource;
    }
}
